home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’96 / Sessions ’96 / ODF- Easy OpenDoc / MacHack(2) / Sources / MacHackView.cpp < prev    next >
Encoding:
Text File  |  1996-06-18  |  4.6 KB  |  163 lines  |  [TEXT/CWIE]

  1. //========================================================================================
  2. //
  3. //    File:                MacHackView.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef MACHACKVIEW_H
  11. #include "MacHackView.h"
  12. #endif
  13.  
  14. #ifndef MACHACKVIEW_H
  15. #include "MacHackView.h"
  16. #endif
  17.  
  18. #ifndef PART_H
  19. #include "Part.h"
  20. #endif
  21.  
  22. #ifndef DEFINES_K
  23. #include "Defines.k"
  24. #endif
  25.  
  26. // ----- Framework Layer -----
  27.  
  28. #ifndef FWFRAME_H
  29. #include "FWFrame.h"
  30. #endif
  31.  
  32. #ifndef FWUTIL_H
  33. #include "FWUtil.h"
  34. #endif
  35.  
  36. #ifndef FWEVEDEF_H
  37. #include "FWEveDef.h"
  38. #endif
  39.  
  40. #ifndef FWPRESEN_H
  41. #include "FWPresen.h"
  42. #endif
  43.  
  44. #ifndef FWSCROLR_H
  45. #include "FWScrolr.h"
  46. #endif
  47.  
  48. #ifndef FWSCLBAR_H
  49. #include "FWSclBar.h"
  50. #endif
  51.  
  52. #ifndef FWGROWBX_H
  53. #include "FWGrowBx.h"
  54. #endif
  55.  
  56. #ifndef FWCONTXT_H
  57. #include "FWContxt.h"
  58. #endif
  59.  
  60. //========================================================================================
  61. // Runtime Information
  62. //========================================================================================
  63.  
  64. #ifdef FW_BUILD_MAC
  65. #pragma segment odfcontainer
  66. #endif
  67.  
  68. //========================================================================================
  69. // CMacHackView
  70. //========================================================================================
  71.  
  72. FW_DEFINE_CLASS_M1(CMacHackView, FW_CSuperView)
  73. FW_DEFINE_AUTO(CMacHackView)
  74.  
  75. // IMPORTANT: the constant below must match the resource label for RMacHackView in views.fr
  76. const FW_ClassTypeConstant LMacHackView = FW_TYPE_CONSTANT('m','h','v','w');
  77. FW_REGISTER_ARCHIVABLE_CLASS(LMacHackView, CMacHackView, CMacHackView::Create, FW_CView::Read, CMacHackView::Destroy, FW_CView::Write)
  78.  
  79. //----------------------------------------------------------------------------------------
  80. // CMacHackView::CMacHackView
  81. //----------------------------------------------------------------------------------------
  82.  
  83. CMacHackView::CMacHackView(Environment* ev) :
  84.     FW_CSuperView(ev),
  85.     fMacHackPart(NULL)
  86. {    
  87.     FW_DO_NOT_DEAD_STRIP(CMacHackView);
  88.     FW_DO_NOT_DEAD_STRIP(FW_CScrollBar);
  89.     FW_DO_NOT_DEAD_STRIP(FW_CScrollBarScroller);
  90.     FW_DO_NOT_DEAD_STRIP(FW_CGrowBox);
  91.     FW_DO_NOT_DEAD_STRIP(FW_CButton);
  92.     
  93.     FW_END_CONSTRUCTOR
  94. }
  95.  
  96. //----------------------------------------------------------------------------------------
  97. // CMacHackView::~CMacHackView
  98. //----------------------------------------------------------------------------------------
  99.  
  100. CMacHackView::~CMacHackView()
  101. {
  102.     FW_START_DESTRUCTOR
  103. }
  104.  
  105. //----------------------------------------------------------------------------------------
  106. //    CMacHackView::PostCreateViewFromStream
  107. //----------------------------------------------------------------------------------------
  108.  
  109. void CMacHackView::PostCreateViewFromStream(Environment* ev)
  110. {
  111.     // Read-in the base resource first
  112.     FW_CSuperView::PostCreateViewFromStream(ev);
  113.     
  114.     FW_CPart* part = GetFrame(ev)->GetPart(ev);
  115.     fMacHackPart = FW_DYNAMIC_CAST(CMacHackPart, part);
  116.     FW_ASSERT(fMacHackPart != NULL);
  117. }
  118.  
  119. //----------------------------------------------------------------------------------------
  120. // CMacHackView::Draw
  121. //----------------------------------------------------------------------------------------
  122.  
  123. void CMacHackView::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
  124. {
  125.     FW_CViewContext vc(ev, this, odFacet, invalidShape);
  126.     
  127.     FW_CRect invalidRect;
  128.     vc.GetClipRect(invalidRect);
  129.     FW_CRectShape::RenderRect(vc, invalidRect, FW_kFill, FW_kRGBLightGray);
  130.  
  131.     FW_CRect extentRect(FW_kZeroPoint, GetExtent(ev));
  132.     invalidRect.Intersection(extentRect);
  133.     FW_CRectShape::RenderRect(vc, invalidRect, FW_kFill, FW_CColor(56000, 56000, 65535));
  134.     
  135.     extentRect.Inset(FW_kFixedNeg1, FW_kFixedNeg1);
  136.     FW_CRectShape::RenderRect(vc, extentRect, FW_kFrame);
  137. }
  138.  
  139. //----------------------------------------------------------------------------------------
  140. //    CMacHackView::Create
  141. //----------------------------------------------------------------------------------------
  142.  
  143. void* CMacHackView::Create(FW_CReadableStream& stream, FW_ClassTypeConstant type)
  144. {
  145. FW_UNUSED(stream);
  146. FW_UNUSED(type);
  147.     FW_SOMEnvironment ev;
  148.     
  149.     // Call minimal constructor.  Data fields will be initialized in InitializeFromStream
  150.     return FW_NEW(CMacHackView, (ev));
  151. }
  152.  
  153. //----------------------------------------------------------------------------------------
  154. //    CMacHackView::Destroy
  155. //----------------------------------------------------------------------------------------
  156.  
  157. void CMacHackView::Destroy(void* object, FW_ClassTypeConstant type)
  158. {
  159. FW_UNUSED(type);
  160.     CMacHackView* self = (CMacHackView*) object;
  161.     delete self;
  162. }
  163.